package com.emm.yixun.openapi.controller;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.emm.yixun.customer.service.channel.ChannelSendHttpMessageService;
import net.sf.ehcache.CacheManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.emm.yixun.common.enums.FunctionTypeEnum;
import com.emm.yixun.common.enums.ModelTypeEnum;
import com.emm.yixun.common.model.Follow;
import com.emm.yixun.common.response.ActionResponse;
import com.emm.yixun.config.DsfConfig;
import com.emm.yixun.customer.service.FollowServiceFacade;
import com.emm.yixun.openapi.anotations.UserOperationLog;
import com.emm.yixun.openapi.vo.SignTestVo;

@Controller
@RequestMapping("/testApi")
public class ApiTestController {
	
	@Autowired
	private FollowServiceFacade followServiceFacade;
	@Autowired
	private ChannelSendHttpMessageService channelSendHttpMessageService;
	
	@Autowired
	private CacheManager cacheManager;
	
	@RequestMapping("/test")
	@UserOperationLog(getFunctionName=FunctionTypeEnum.FUNCTIONTYPE_4,getModelName=ModelTypeEnum.MODELTYPE_1)
    public @ResponseBody ActionResponse<Follow> test(){
		ActionResponse<Follow> result=new ActionResponse<Follow>();
		return result;
    }
	
	@RequestMapping("/signTest")
	public void signTest(HttpServletRequest request, HttpServletResponse response, SignTestVo stVo){
		boolean flag = DsfConfig.validSign(stVo);
		try {
			response.getWriter().write("flag = " + flag);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@RequestMapping("/sendChannelStatus")
	public void sendChannelStatus(Long id, String type, boolean retreatFlag){
		channelSendHttpMessageService.sendTransaction(id, type, retreatFlag);
	}
}
